/******************************************************************
 * Title: unscrun.sc
 * Author:  Brian Peck
 * Date: Spring 2011
 * Description: Specification model for unscrun (in DES)
 *****************************************************************/
#include <stdio.h>
import "i_receiver";
import "i_sender";

behavior desUnscrun(i_receiver ir, i_sender is)
{
    const char* bName = "desUnscrun";
    
    void main(void) {
      unsigned long outofData[2];
      unsigned char into;
      int i, j;
 
    while (1) {
      ir.receive(&outofData[0], sizeof(unsigned long));
      ir.receive(&outofData[1], sizeof(unsigned long));

      printf("%s: Received block[0]: 0x%lx, block[1]: 0x%lx\n", bName, outofData[0], outofData[1]);
      
      for (i=0; i<2; i++)
      {
        for (j=0; j<4; j++)
        { 
           into = (outofData[i] >> 8*(3-j)) & 0x00ff;
           is.send (&into, sizeof(char));
         }
      }  
     }
   } //end main 
}; // end behavior unscrun
